package com.cjkj.system.controller;

import com.cjkj.common.core.domain.R;
import com.cjkj.system.api.domain.APIEquipmentUsageRecords;
import com.cjkj.system.domain.TEquipmentUsageRecords;
import com.cjkj.system.service.ITEquipmentUsageRecordsService;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/equipmentUsageRecord")
public class EquipmentUsageRecordsController {

    @Resource
    private ITEquipmentUsageRecordsService equipmentUsageRecordsService;

    @GetMapping("/get/{equipmentNo}")
    public R<APIEquipmentUsageRecords> getRecordsByEquipment(@PathVariable("equipmentNo") String equipmentNo){
        return R.ok(equipmentUsageRecordsService.getRecordsByEquipment(equipmentNo));
    }

    /**
     * 修改多参数监测仪使用状态
     * @param dto
     * @return
     */
    @PostMapping("/updateUseRecordStatus")
    public R<Integer> updateUseRecordStatus(@RequestBody APIEquipmentUsageRecords dto){
        TEquipmentUsageRecords records = new TEquipmentUsageRecords();
        BeanUtils.copyProperties(dto, records);
        return R.ok(equipmentUsageRecordsService.updateTEquipmentUsageRecords(records));
    }

}
